/**
 * Copyright ©2012-2018 HopeHaiyang Corporation, All Rights Reserved
 * http://www.wuhanhope.com
 */
package hujia.profile.server.img;

import hujia.profile.dao.RoleRepository;
import hujia.profile.domain.Role;
import hujia.profile.server.header.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Optional;

/**
 * class info
 *
 * @author hujia
 *         Create at 2018/7/31 9:48
 */
@Service
public class RoleServiceImg implements RoleService {

    @Autowired
    private RoleRepository repository;

    @Override
    public Optional<Role> getByRoleName(String roleName) {
        return repository.findByRoleName(roleName);
    }

    @Override
    public Role add(Role role) {
        role.setGmtModified(new Date());
        role.setGmtCreate(new Date());
        return repository.save(role);
    }
}
